test(coverage/nats): drive queueprovider/nats to 100% (was 80.4%)#29
Merged
Conversation
Adds targeted coverage for every error branch in queueprovider/nats: * builder() — bad operator seed, opKP.PublicKey() fail, all defaults applied, UseTLS scheme flip * SetResolverPusher — nil-arg resets to no-op (previously could nil-deref) * IssueTenantCredentials — empty ResourceToken validation, SystemAccount rejection, legacy_open short-circuit when operator seed unset, pusher-error propagation, every nkeys.* / jwt.* post-create error branch (createAccount/PublicKey/Seed, createUser/PublicKey/Seed, sign account JWT, sign user JWT, FormatUserConfig) * RevokeTenantCredentials — empty keyID no-op, legacy_open no-op, cache-miss no-op, encode-revocation failure, push-failure propagation * RevokeWithSeed — empty seed no-op, legacy_open no-op, FromSeed failure, derived public key failure, encode failure, push-failure propagation * lookupCachedByPub — non-matching entry continue-scanning branch * connectionURL — useTLS=true tls:// scheme * Name — "nats" identifier * Capabilities — full shape (PerTenantAccounts/SubjectScopedAuth/StreamIso=true, BasicAuth=false) * canonicalSubject — auto-derive when Subject empty Source refactor: 4 package-level test seams (createAccountKP, createUserKP, formatUserCreds, parseOperatorKP) so unit tests can inject failing implementations for branches that the real nkeys/jwt libraries never trip in practice. In production these seams alias the upstream constructors 1:1 — zero behavior change. Coverage: 80.4% → 100.0% (all 14 functions in nats.go). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
common/queueprovider/natsline coverage from 80.4% → 100.0% (all 14 functions innats.go).createAccountKP,createUserKP,formatUserCreds,parseOperatorKP) so unit tests can inject failing implementations for branches the real nkeys/jwt libraries never trip in practice. Production behavior unchanged — seams alias upstream constructors 1:1.Test plan
go test ./queueprovider/nats -coverprofile=/tmp/c.out→ 100.0% of statementsgo tool cover -func=/tmp/c.out→ every function at 100%go test ./queueprovider/nats -count=2 -race→ greengo vet ./...cleango test ./...green (16 packages)🤖 Generated with Claude Code